import axios from 'axios';

export interface BizGoodsImageRecord {
  id: number;
  title: string;
  path: string;
  url: string;
  sort: number;
  goods_id: number;
  created_at: string;
  updated_at: string;
}

export interface BizGoodsImageForm {
  id?: number;
  title?: string;
  path: string;
  sort?: number;
  goods_id: number;
}

export interface ImageSortData {
  id: number;
  sort: number;
}

export interface ImageSortRequest {
  images: ImageSortData[];
}

// 获取商品相册列表
export function queryBizGoodsImages(params: { goods_id: number }) {
  return axios.get<BizGoodsImageRecord[]>('/admin/biz-goods/get-images', { params });
}

// 添加商品图片
export function addBizGoodsImage(data: BizGoodsImageForm) {
  return axios.post<BizGoodsImageRecord>('/admin/biz-goods/add-image', data);
}

// 删除商品图片
export function delBizGoodsImage(id: number) {
  return axios.post('/admin/biz-goods/delete-image', { id });
}

// 更新图片信息
export function updateBizGoodsImage(data: BizGoodsImageForm) {
  return axios.post<BizGoodsImageRecord>('/admin/biz-goods/update-image', data);
}

// 更新图片排序
export function updateBizGoodsImageSort(data: ImageSortRequest) {
  return axios.post('/admin/biz-goods/update-image-sort', data);
} 